#!/bin/bash
#------------------------------------------
# desc:
#     awk命令封装
# author:
#     dockerlin@163.com
# ------------------------------------------

# ----------------------------
# 返回字符串在另一个字符串的位置
# $1 搜索字符串
# $2 查找字符串
# 例如：awk 'BEGIN{ print index("abcdge","bc") }'
# usage: pos=`cxlib_awk_strpos "abcdge" "bc"`
# pos 大于 0 表示搜索到
# ----------------------------
function cxlib_awk_strpos(){
    if [ -z "$1" ]; then echo 0; fi
    if [ -z "$2" ]; then echo 0; fi
    eval "awk 'BEGIN{ print index(\"$1\",\"$2\") }'"
}
